﻿using Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace RSATest
{
    class Program
    {
        static void Main(string[] args)
        {
            // AES

            string encryptStr, decryptStr, key;
            key = "ae125efkk4454eeff444ferfkny6oxi8";
            encryptStr = "C#AES加密字符串";
            Console.WriteLine("==============  256位AES加密  ============\n");
            Console.WriteLine("加密前的字符串：" + encryptStr);
            Console.WriteLine("密钥：" + key);
            Console.WriteLine();
            decryptStr = AESHelper.Encrypt(encryptStr, key);
            Console.WriteLine("加密后的字符串：" + decryptStr);

            encryptStr = AESHelper.Decrypt(decryptStr, key);
            Console.WriteLine("解密后的字符串：" + encryptStr);
            Console.ReadKey();

            //RSA

            string str = "{\"sc\":\"his51\",\"no\":\"1\",\"na\":\"管理员\"}{\"sc\":\"@his51\",\"no\":\"1\",\"na\":\"管理员\"}{\"sc\":\"his51\",\"no\":\"1\",\"na\":\"管员\"}{\"sc\":\"his522";
            RSAHelper.RSAKey keyPair = RSAHelper.GetRASKey();
            Console.WriteLine("公钥:" + keyPair.PublicKey + "\r\n");
            Console.WriteLine("私钥:" + keyPair.PrivateKey + "\r\n");
            Debug.WriteLine("公钥：" + keyPair.PublicKey);
            Debug.WriteLine("密钥：" + keyPair.PrivateKey);

            string en = RSAHelper.Encrypt(str, keyPair.PrivateKey);
            Console.WriteLine("加密后：" + en + "\r\n");
            Console.WriteLine("解密：" + RSAHelper.Decrypt(en, keyPair.PublicKey) + "\r\n");
            Console.ReadKey();
        }
    }
}
